﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using smp.ButterflyCakes.Repository;
using smp.ButterflyCakes.Repository.Implementation;
using smp.ButterflyCakes.Repository.Interfaces;

namespace smp.ButterflyCakes.Web.Controllers
{
    public partial class BaseController : Controller
    {
        protected readonly ILog Log;
        protected readonly ICache Cache;

        public BaseController(ILog log, ICache cache)
        {
            Log = log;
            Cache = cache;
        }

        public BaseController()
        {
            Log = new Log();
            Cache = new Cache();
        }

        //todo replace this with and action filter
        protected Guid GetActualId(string id)
        {
            Guid value;
            if(!Guid.TryParse(id, out value))
            {
                throw new Exception("Invalid id value used : " + id);
            }
            return value;
        }
    }
}
